﻿@helper GetImage(string image)
{
    var coded = image as string;
    
    if (image == null || image.Length < 8)
    {
        <img src="~/img/default-image.jpg" alt="Account Picture" class="profile-picture" />
    }
    else
    {
        //"137 80 78 71 13 10 26 10" - first 8 bytes of PNG

        var bytes = Convert.FromBase64String(image);
        if (bytes[0] == 137 && bytes[1] == 80)
        {
            <img src="data:image/png;base64,@image" alt="Account Picture" class="profile-picture" />
        }
        else
        {
            <img src="data:image/jpg;base64,@image" alt="Account Picture" class="profile-picture" />
        }
    }
}
